<?php
require_once(dirname(__FILE__)."/../inc/common.php");
/*******************************************************************************************
'*******************************************************************************************/
if (paramset==0 || runMode=="forgedStatic"){
    $paras = replaceStr(QUERY_STRING,fileSuffix,'');
    if (strpos($paras, "-") > 0) {
	    $parasArray = explode("-",$paras); $id = $parasArray[0]; $page = $parasArray[1];
    } else {
	    $id = $paras; $page = 1;
    }
} else {
	$id=getForm(paramid,"both");$page=getForm(parampage,"both");
}
if (empty($id)) {
	echoSaveStr("null");exit();
} else {
	if (is_numeric($id)){ $id = intval($id); } else { echoSaveStr("safe");exit();}
}
if (empty($page)) {
	$page=1;
} else {
	if (is_numeric($page)) { $page = intval($page); } else { echoSaveStr("safe");exit();}
}
if (iscache == '1'){
   checkCourt($id);
}
echoChannel($id);

function echoChannel($typeId){
	global $page,$t1;
	$y = explode(",", getTypeNameTemplateArrayOnCache($vType));$z = ifthen(empty($y[1]), "channel.html", $y[1]);$x = DJCMS_TEMPLATE.$z;
	if (strpos(" ,".getHideTypeIDS().",",",".$typeId.",") > 0) { OutNotFound("channel");}
	$typeIds = getTypeIdOnCache($typeId);
	djcms::$currentTypeId = $typeId;$cacheName = "parse_channel_".$typeId;
	if (cacheStart==1){
		if (djcms::$content = memory('get', $cacheName)) {
        } else {
            parseChannelPart($x,$y[0]);
			memory('set', $cacheName, djcms::$content);
        }
	} else {
			parseChannelPart($x,$y[0]);
	}
	djcms::$content = replaceStr(djcms::$content,"{channelpage:page}",$page);
    djcms::ParsePageList($typeIds,$page,"channel");
	djcms::parseIf();
	echo replaceStr(djcms::$content,"{yh:runinfo}",getRunTime($t1));
}

function parseChannelPart($x,$y)
{
	djcms::$content=loadFile($x);
	djcms::parseTopAndFoot();
	djcms::parseSelf();
	djcms::parseGlobal();
	$z = getTypeField(djcms::$currentTypeId,"m_keyword,m_description","");
	$content = replaceStr(replaceCurrentTypeId(djcms::$content),"{channelpage:typetext}",getTypeTextOnCache(djcms::$currentTypeId));
	$content = replaceStr(replaceStr($content,"{channelpage:keywords}",$z[0]),"{channelpage:description}",$z[1]);
	djcms::$content = replaceStr($content,"{channelpage:typename}",$y);
	djcms::parseMenuList("");
	djcms::parseNewsList();
	djcms::parseAreaList();
	djcms::parseVideoList();
	djcms::parseTopicList();
}
?>